import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface"; export default class UpdateOperation { protected readonly collectionName: string; private readonly baseQuery; private readonly path; private readonly ResponseHelper; private allDataWithFileName; private sort; constructor(collectionName: string, path: string, baseQuery: object | any); /** * Updates a single document that matches the base query. * * Routed through a single-operation Transaction, so the update is WAL-backed: * locking, the fresh re-read under lock, atomic file replacement, and index * sync are all handled by Transaction/TransactionIndexManager - the same * machinery insert() already uses. This method's own job is just picking * *which* document to target (honoring .Sort()), since Transaction.update() * touches every document a query matches. * * @param newData - The new data to replace the existing document * @returns A Promise resolving to: * - Success with updated data and previous data if successful * - Error if no document matched or the transaction failed */ UpdateOne(newData: object | any): Promise; /** * Updates multiple documents that match the base query. * * Routed through a single Transaction covering the whole query, so the batch * is WAL-backed: locking, fresh re-reads, atomic file replacement, and index * sync (one rewrite per affected index field, not one per document) are all * handled by Transaction/TransactionIndexManager. * * @param newData - The new data to replace the existing documents * @returns A Promise resolving to: * - Success with the count and IDs of updated documents * - Error if no document matched or the transaction failed */ UpdateMany(newData: object | any): Promise; /** * to be sorted to the query * @param {object} sort - The sort to be set. * @returns {UpdateOperation} - An instance of the UpdateOperation class. */ Sort(sort: object | any): UpdateOperation; /** * Resolves the single document UpdateOne should target: runs the same * index-or-full-scan search UpdateMany's Transaction path uses internally, * then applies .Sort() (if set) and picks the first match - matching the * "one specific document" semantics UpdateOne has always had. * * @returns The target document's ID, or null if nothing matched. */ private resolveTargetDocumentId; /** * Loads all buffer raw data from the specified directory. * * @returns {Promise} A promise that resolves to a success or error response. */ private LoadAllBufferRawData; }